<script>
    function myform_submit() {
        if($("#siteId").val() == ''){
            alert('请选择维修站点');
            return false;
        }
        if($("#categoryId").val() == ''){
            alert('请选择产品类型');
            return false;
        }
        if($("#gradeId").val() == ''){
            alert('请选择维修项级别');
            return false;
        }
        if($("#customerId").val() != ''){
            if(!isempty('price','请输入客户自定义金额'))return false;
        }else{
            if(!isempty('brand_price','请输入品牌金额'))return false;
            if(!isempty('merchant_price','请输入商家金额'))return false;
            if(!isempty('individual_price','请输入个人金额'))return false;
        }
        return true;
    }
</script>

<script>
    function myform_submit() {
        if($("#siteId").val() == ''){
            alert('请选择维修站点');
            return false;
        }
        if($("#categoryId").val() == ''){
            alert('请选择产品类型');
            return false;
        }
        if($("#customerId").val() == ''){
            alert('请选择需要自定义费用的客户');
            return false;
        }
        return true;
    }
    //列表
    $(function(){
        $("select").change(function(){
            $.post("<?=blang_url('common/Com_ajax/laborPrice')?>/",$("#formData select").serialize(), function(data){
                    $('#priceConten').html(data);
                }
            );
            console.info($("#formData select").serialize());
        });
        $("select[data-edit-select]").filterSelect();
    })
</script>


<!--菜单 start-->
<?php $this->load->view('defaults/common/left');?>
<!--菜单 end-->
<div id="content">
    <div class="page-header">
        <div class="container-fluid">
          <h1><?=lang('menu_yhgl')?></h1>
          <?=$this->breadcrumb->generateHTML();?>
        </div>
    </div>
    <div class="container-fluid">
        <div class="panel panel-default">
          <div class="panel-heading">
            <h3 class="panel-title"><i class="fa fa-plus"></i>增加自定义费用</h3>
          </div>
          <div class="panel-body">
            <form class="form-horizontal" action="<?=blang_url('users/CustomerPrice/'.$post_type)?>" method="post" name="productform" onsubmit="return myform_submit()" autocomplete="off" >
                <div class="form-group">
                    <label class="col-sm-2 control-label">维修站点</label>
                    <div class="col-sm-10">
                        <select class="form-control" name="site_id" id="siteId" >
                            <option value="" >--请选择--</option>
                            <?php foreach ($serviceCenterList as $rs):?>
                                <option value="<?=$rs['id']?>"  >
                                    <?=$rs['name_ch']?>
                                </option>
                            <?php endforeach;?>
                        </select>
                        <label style="color:#1e91cf;">ps：金额货币为站点货币</label>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">产品类型</label>
                    <div class="col-sm-10">
                       <select class="form-control" name="category_id" id="categoryId">
                            <option value="" >--请选择--</option>
                            <?php foreach ($categoryList as $rs):?>
                                <option value="<?=$rs['id']?>"  >
                                    <?=$rs['name_ch']?>
                                </option>
                            <?php endforeach;?>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">维修项等级</label>
                    <div class="col-sm-10">
                        <select class="form-control" name="grade" id="gradeId">
                            <option value="" >--请选择--</option>
                            <?php foreach ($gradeList as $rs):?>
                                <option value="<?=$rs['id']?>"  >
                                    <?=$rs['name_ch']?>
                                </option>
                            <?php endforeach;?>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">客户</label>
                    <div class="col-sm-10">
                        <select name="customer_id" id="customerId" class="form-control getLabor">
                            <option value="" >--请选择--</option>
                            <?php foreach ($customerList as $rs):?>
                                <option value="<?=$rs['id']?>"  > <?=$rs['name']?> </option>
                            <?php endforeach;?>
                        </select><br>
                        <select name="brand_id" id="brandId" class="form-control getLabor">
                            <option value="" >--请选择--</option>
                            <?php foreach ($brandList as $rs):?>
                                <option value="<?=$rs['id']?>" <?=$optBrand[$rs['id']]?> > <?=$rs['name']?> </option>
                            <?php endforeach;?>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">客户自定义金额</label>
                    <div class="col-sm-10">
                        <input class="form-control" name="price"  value="" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">基础品牌金额</label>
                    <div class="col-sm-10">
                       <input class="form-control" name="brand_price"  value="" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">基础商家金额</label>
                    <div class="col-sm-10">
                        <input class="form-control" name="merchant_price"  value="" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">基础个人金额</label>
                    <div class="col-sm-10">
                        <input class="form-control" name="individual_price"  value="" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label"></label>
                    <div class="col-sm-10">
                       <input class="btn btn-primary" style="padding:8px 45px;" type="submit" value="<?=lang('public_tj')?>" name="submits" />
                    </div>
                </div>
            </form>
          </div>
        </div>
    </div>
 
</div>




